


        var numRun = readyToGetCity = readyToWriteCity = null;
        var step = 300;

        var newsSwiper = new Swiper('.newsSwiper',{
            slidesPerView: 2,
            spaceBetween: 20,     
            pagination: {
                el: '.newsSwiper .swiper-pagination',
                clickable: true
            },
            breakpoints:{
                1024: {
                    slidesPerView: 1
                }
            }
        })

        $(document).ready(function(){
            $(window).scroll(function(){
                var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
                if(window.innerWidth <= 1024){
                    if(scrollTop != 0 && $('header nav')[0].className.indexOf('addBg') < 0){
                        $('header nav').addClass('addBg');
                    }else if(scrollTop == 0 && $('header nav')[0].className.indexOf('addBg') >= 0){
                        $('header nav').removeClass('addBg');
                    }
                }else{
                    var navH = $('header nav')[0].offsetHeight;
                    if(scrollTop >= window.innerHeight - navH && $('header nav')[0].className.indexOf('addBg') < 0){
                        $('header nav').addClass('addBg');
                    }else if(scrollTop < window.innerHeight - navH && $('header nav')[0].className.indexOf('addBg') >= 0){
                        $('header nav').removeClass('addBg');
                    }
                }
                
            })
            for(var t = 1;t < $('.ttl').length;t++){
                var txt = $('.ttl').eq(t).find('.eng').text();
                var fstLtr = txt[0];
                txt = txt.substring(1);
                $('.ttl').eq(t).find('.eng').text(txt);
                var span = '<span>' + fstLtr + '</span>';
                $('.ttl').eq(t).find('.eng').prepend(span);
            }

            var numFinal = parseInt($('main .pageHead .content .tip .num').attr('data-final'));
            numRun = setInterval(function(){
                var now = parseInt($('main .pageHead .content .tip .num').text().split(',').join(''));
                if(now == numFinal){
                    clearInterval(numRun);
                }
                var val;
                if(numFinal - now < step){
                    val = numFinal;
                }else{
                    val = now + Math.ceil(numFinal / step);
                }
                val = String(val);
                if(val >= 1000 && val < 1000000){
                    val = val.split('');
                    val.splice((val.length - 3),0,',');
                    val = val.join('');
                }else if(val >= 1000000){
                    val = val.substr(0,1) + ',' + val.substring(1);
                    val = val.substr(0,5) + ',' + val.substring(5);
                }

                $('main .pageHead .content .tip .num').text(String(val));
                

            },10)

            

            $('main .send .window form .submit').click(function(){
                for(var i = 0;i < $('main .send .window form input').length;i++){
                    var val = $('main .send .window form input').eq(i).val();
                    if(val.length == 0){
                        alert('请填写您的' + $('main .send .window form input').eq(i).siblings('span').text());
                        return false;
                    }
                    if($('main .send .window form input').eq(i).attr('id') == 'checkerName'){
                        var regExp = /^[\u4e00-\u9fa5]+$/;
                        if(!val.match(regExp)){
                            alert('姓名必须为简体汉字');
                            return false;
                        }                
                    }else{
                        var regExp = /^[0-9]+$/;
                        if(!regExp.test(val) || val.length != 11){
                            alert('请填写正确的手机号');
                            return false;
                        }
                    }
                }
                var obj = {
                    cityId:$('#area').attr('data-id'),
                    keyword:$('#name').val(),
                    name:$('#checkerName').val(),
                    phone:$('#checkerNumber').val(),
                    tradeId:$('#trade').attr('data-id'),
                    recordType:$('header nav .links .active').text() != '公司核名'?'1':'2',
                    type:$('#compType').attr('data-id')
                }
                sessionStorage.setItem('checkerName',$('#checkerName').val());
                sessionStorage.setItem('checkerNumber',$('#checkerNumber').val());
                arr = [];
                if(obj.recordType == '1'){
                    delete obj.keyword;
                    obj.size = $('#nums').attr('data-id');
                }
                for (let i in obj) {
                    arr.push(obj[i]);
                }
                if(obj.recordType == '1'){
                    arr.splice(arr.length - 1,1);
                    arr.splice(1,0,$('#nums').attr('data-id'));
                }
                arr.splice(2,2);
                arr.splice(arr.length - 2,1);
                arr.splice(0,0,$('#area').attr('data-proid'));
                $.ajax({
                    type: "POST",
                    url: realm + "/api/toNaming",
                    data: JSON.stringify(obj),
                    dataType: "json",
                    contentType: 'application/json',
                    success: function(data){
                        if(data.message == "核名成功"){
                            sessionStorage.setItem('lastSearch',arr);
                            window.location.href = 'check.html';
                        }else if(data.message == "起名成功"){
                            for(var a = 0;a < data.data.length;a++){
                                nameArr.push(data.data[a].name);
                            }
                            sessionStorage.setItem('lastSearch',arr);
                            sessionStorage.setItem('compName',nameArr);
                            window.location.href = 'named.html';
                        }
                    },
                    error:function(data){
                        console.log(data);
                    }
                })
            })
            $('main .send .close').click(function(){
                $('main .send input').val('');
                $('main .send').removeClass('show');
            })
            $('main .pageHead .content form .submit').click(function(){
                var pass = true;
                for(var i = 0;i < $('main .pageHead .content form input').length;i++){
                    var val = $('main .pageHead .content form input').eq(i).val();
                    if(val.length == 0){
                        if($('main .pageHead .content form input').eq(i).parent()[0].className.indexOf('hidden') >= 0) continue;
                        if($('main .pageHead .content form input').eq(i).attr('id') == 'name'){
                            alert('请输入字号')
                        }else{
                            alert('请选择' + $('main .pageHead .content form input').eq(i).siblings('span').text());
                        }
                        pass = false;
                        break;
                    }
                    if($('main .pageHead .content form input').eq(i).attr('id') == 'name'){
                        var regExp = /^[\u4e00-\u9fa5]+$/;
                        if(!val.match(regExp)){
                            alert('字号必须为简体汉字');
                            pass = false;
                            break;
                        }                
                    }
                }
                if(pass){
                    $('main .send').addClass('show');
                }
            })
            /*readyToGetCity = setInterval(function(){
                
                if(provinces.length){
                    for(var p = 0;p < provinces.length;p++){
                        var proId = provinces[p].id;
                        var pro = provinces[p].name;
                        var obj = {id:proId};
                        var html = "<div class='item flex'><p class='province'>" + pro + "</p><p class='city flex'></p></div>"
                        $('.area.list').append(html);
                        $.ajax({
                            type: "POST",
                            url: realm + "/api/getCityList",
                            data: JSON.stringify(obj),
                            dataType: "json",
                            contentType: 'application/json',
                            success: function(data){
                                console.log(data);
                                cities.push(data.data);
                            },
                            error:function(data){
                                console.log(data);
                            }
                        });
                    }
                    clearInterval(readyToGetCity);
                }
            },10)

            readyToWriteCity = setInterval(function(){
                if(provinces.length == cities.length && provinces.length){
                    console.log(cities);
                    for(var c = 0;c < cities.length;c++){
                        for(var n = 0;n < cities[c].length;n++){
                            var city = cities[c][n].name;
                            var inner = "<span>" + city + "</span>";
                            $('.area.list .item').eq(c).find('.city').append(inner);
                        }
                        
                    }
                    clearInterval(readyToWriteCity);
                }
            },10)*/

        })
        $(document).keyup(function(e){
            var event = e || window.event;
            if(event.keyCode == 13 && $('main .send')[0].className.indexOf('show') >= 0){
                $('main .send .window form .submit')[0].click();
            }
        })